/**
 * Created by sun on 2016/9/9.
 */

define(function (require) {
    var app = require('/../js/app');
    require('ui-table');
    app.useModule("ui.table");

    var toastr =require('toastr');
    app.controller('lockCtrl', ['$scope','$http' ,function ($scope, $http) {
        $scope.now={};
        $scope.add={};
        //获取
        $scope.orderParams = {
            url: "/sys/configParam/getList",
            ajax:{

            }
        };

        //点击编辑后的弹出
        $scope.edit= function (paramKey) {
            $scope.detailsModal=!$scope.detailsModal;
            $http({
                method : 'POST',
                url :"/sys/configParam/getOne",
                data: {
                    key:paramKey
                }
            }).success(function(data) {
                console.info(data);
                $scope.list = data;
            }).error(function(data, status) {
            });
        };


        //弹出框修改后的确定
        $scope.saveSubmit= function () {
            $http({
                method : 'POST',
                url :"/sys/configParam/update",
                data:{
                    key:$scope.list.paramKey,
                    value:$scope.list.paramValue
                }
            }).success(function(data) {
                console.info(data);
                if(data.result=="success"){
                    toastr.success("修改成功！");
                    $scope.detailsModal=!$scope.detailsModal;
                }
                else{
                    if(data.messageText){
                        toastr.error(data.messageText);
                    }
                    else{
                        toastr.error("修改失败");
                    }
                }
            }).error(function(data, status) {
            });
        };

    }]);


});